﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using CBE.UI.Control.Presenters;

namespace CBE.UI.Control.Views
{
    /// <summary>
    /// Interaction logic for CronogramaTurnosWindow.xaml
    /// </summary>
    public partial class CronogramaTurnosWindow : Window, ICronogramaTurnosView
    {
        public CronogramaTurnosPresenter Presenter { get; set; }
        public DateTime Date { get; set; }

        public CronogramaTurnosWindow(DateTime date)
        {
            InitializeComponent();

            scheduleControl.DisplayedDates = new System.Collections.ObjectModel.ObservableCollection<DateTime> {
                date
                //, date.AddDays(1)
            };
            scheduleControl.Appointments = new System.Collections.ObjectModel.ObservableCollection<Schedule.Appointment>();
            
            Date = date;

            this.InitializePresenter();
        }

        private void InitializePresenter()
        {
            Presenter = new CronogramaTurnosPresenter(this, Date);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            PrintDialog pr = new PrintDialog();
            pr.PrintVisual(this.scheduleControl, "Cronograma de turnos");
        }

        public void AddAppointment(String title, String summary, DateTime startDate, DateTime endDate)
        {
            this.AddAppointment(title, summary, startDate, endDate, String.Empty);
        }

        public void AddAppointment(String title, String summary, DateTime startDate, DateTime endDate, String location) 
        {
            scheduleControl.Appointments.Add(
                new Schedule.Appointment
                {
                    Title = title,
                    Summary = summary,
                    Start = startDate,
                    End = endDate,
                    Location = location
                });
        }

    }
}
